﻿<?php
$string = <<<XML
<?xml version='1.0'?> 
<document>
	
</document>

XML;

/*$xml = simplexml_load_string($string);
echo "<pre>";
//echo $xml->asXML();
print_r($xml);
echo "</pre>";*/

$name = '';

$sxe = new SimpleXMLElement($string);
$sxe->addAttribute('type', 'documentary');

$movie = $sxe->addChild('movie');
$movie->addChild('title', 'PHP2: More Parser Stories');
$movie->addChild('plot', 'This is all about the people who make it work.');

$characters = $movie->addChild('characters');
$character  = $characters->addChild('character');
$character->addChild('name', 'Mr. Parser');
$character->addChild('actor', $name);

$rating = $movie->addChild('rating', '5');
$rating->addAttribute('type', 'stars');
 
//echo "<pre>";
echo( $sxe->asXML());
//echo "</pre>"; 
?>